package com.jushu.storbox.service;

import java.util.List;

import android.util.Log;

import com.jushu.storbox.ShareDriveApplication;
import com.huawei.sharedrive.sdk.android.exception.ClientException;
import com.huawei.sharedrive.sdk.android.modelV2.request.UserSearchRequestV2;
import com.huawei.sharedrive.sdk.android.modelV2.response.UserInfoV2;
import com.huawei.sharedrive.sdk.android.modelV2.response.UserListResponseV2;
import com.huawei.sharedrive.sdk.android.serviceV2.UserClientV2;
public class RemoteMailListService implements IRemoteMailListService{
	private UserClientV2 client;
	private List<UserInfoV2> adUserList;
	private UserSearchRequestV2 adUserSearchRequest = null;

	@Override
	public List<UserInfoV2> queryMailList(String keyText) throws ClientException
	{
		if (client == null) 
		{
			client = ShareDriveApplication.getInstance().getUserClientV2();
		}
		adUserSearchRequest = new UserSearchRequestV2();
		adUserSearchRequest.setKeyword(keyText);
		UserListResponseV2 response  = client.listUser(ShareDriveApplication.getInstance().getAuthorization(), adUserSearchRequest);
		adUserList = response.getUsers();
		for (UserInfoV2 aadUserList : adUserList) {
			Log.e("~~", "Name:"+aadUserList.getName()+",clouduserid:"+aadUserList.getCloudUserId());
		}
		if(null != adUserList)
		{
			if (adUserList.size() > 0) 
			{
				return adUserList;
			}
			else 
			{
				return null;
			}
		}
		else
		{
			return null;
		}
	}
}
